﻿@using Entidades.Sistema.Produccion
@using Entidades.Sistema.Venta
@using System.Collections.ObjectModel;

@model DiagramacionProduccion
<script src="../../Scripts/TreeView.js"></script>

@using (Html.BeginForm("PostPedidosPartial", "DiagramacionProduccion", FormMethod.Post))
{
    <strong style="color: Blue">@ViewBag.Message</strong><br />
    

    
    @Html.HiddenFor(model => model.IdDiagramacionProduccion)
    @Html.HiddenFor(model => model.Estado)

    <div class="vertComponentContainer">

        
        @Html.DevExpress().TreeView(
            settings => {
                settings.Name = "tvPedidos";
                settings.AllowCheckNodes = true;
                settings.AllowSelectNode = true;
                settings.CheckNodesRecursive = true;
                settings.EnableAnimation = true;
                settings.EnableHotTrack = true;
                settings.ShowTreeLines = true;
                settings.ShowExpandButtons = true;
                settings.Width = 500;

                foreach (Pedido ped in Model.Pedidos)
                {
                    settings.Nodes.Add(node =>
                        
                    {
                        node.Text = string.Format("Pedido[{0}] - Cliente: {1}", ped.IdPedido.ToString(), ped.Cliente.Nombre);
                        
                        foreach(DetallePedido det in ped.DetallePedidos)
                        {
                            node.Nodes.Add(subNode =>
                            {
                                subNode.Text = string.Format("Detalle[{0}|{1}] - Producto: {2} - Cantidad: {3}", ped.IdPedido.ToString(), det.IdDetallePedido.ToString(), det.Producto.Nombre, det.Cantidad.ToString());                                
                            });                        
                        };                        
                    });
                };

                settings.PreRender = (source, e) => {
                    ASPxTreeView treeView = (ASPxTreeView)source;
                    treeView.ExpandToDepth(0);
                };

                settings.ClientSideEvents.CheckedChanged = "tvPedidos_OnCheckedChanged";
                settings.ClientSideEvents.Init = "tvPedidos_OnInit";
            }).GetHtml()

        <hr />
        <div class="line">
        @Html.DevExpress().Label(
            settings => {
                settings.ControlStyle.CssClass = "label";
            }).GetHtml()
            @Html.DevExpress().Button(buttonSettings => {
                buttonSettings.Name = "btnGoToConfiguracionTab;";
                buttonSettings.Text = "Siguiente";
                buttonSettings.UseSubmitBehavior = true;
                buttonSettings.Enabled = ViewBag.NoExistenPedidos;
            }).GetHtml()
            @Html.DevExpress().Button(
            btnSettings =>
            {
                btnSettings.Name = "btnCancel";
                btnSettings.ControlStyle.CssClass = "button";
                btnSettings.Text = "Cancelar";
                btnSettings.ClientSideEvents.Click = "function(s, e){ document.location='" + DevExpressHelper.GetUrl(new { Controller = "DiagramacionProduccion", Action = "CancelDiagramacionProduccionUpdatePartial", IdDiagramacionProduccion = Model.IdDiagramacionProduccion }) + "'; }";
            }).GetHtml()
        </div>
           
    </div>
    <div>
        <input type="hidden" id="hf" name="hf" value='@ViewBag.Pedidos' />
    </div>
}




